<?php

namespace app\common\controllers;

use app\common\services\UploadService;
use yii\base\UserException;
use yii\web\UploadedFile;

class UploadController extends CorsController {

    //上传图片
    public function actionUploadImg(){
        $file = UploadedFile::getInstanceByName("file");

        if($result = UploadService::uploadFile($file)){
            return $result;
        }else{
            throw new UserException(UploadService   ::getError());
        }
    }
}